package kr.saeildamil.androidstudy.ch08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

public class HandleEvent extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyView mv = new MyView(this);
		setContentView(mv);
	} // end of oncreate

	public class MyView extends View {

		public MyView(Context context) {
			super(context);
		}

		public boolean onTouchEvent(MotionEvent event) {
			super.onTouchEvent(event);
			float x = event.getX();
			float y = event.getY();
			if (event.getAction() == MotionEvent.ACTION_DOWN) { // 눌렀냐는 말임
				Toast.makeText(HandleEvent.this,
						"Point " + x + ", " + y + "를  Action Down!",
						Toast.LENGTH_LONG).show();
				return true;
			} else if (event.getAction() == MotionEvent.ACTION_UP) {
				Toast.makeText(HandleEvent.this,
						"Action Up!",
						Toast.LENGTH_LONG).show();
				return true;
			}

			return false;
		} // end of method onTouchEvent

	} // end of MyView class

} // end of main class
